<?php


namespace App\Http\Controllers\Admin\Auth;

use App\Http\Controllers\{
    Admin\Controller,
    Traits\LoginTrait
};
use App\Http\Requests\Auth\LoginRequest;
use App\Http\Requests\Auth\SmsLoginRequest;

class LoginController extends Controller
{
    use LoginTrait;

    /**
     * 显示登录页面
     *
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
     */
    public function getLogin()
    {
        return $this->view('admin.auth.login');
    }

    /**
     * 账号密码登录
     *
     * @param LoginRequest $request
     *
     * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
     * @throws \Illuminate\Validation\ValidationException
     */
    public function postLogin(LoginRequest $request)
    {
        $this->loginWithPassword($request);

        return $this->intended();
    }

    /**
     * 显示短信登录页面
     *
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
     */
    public function getSmsLogin()
    {
        return $this->view('admin.auth.login-sms');
    }

    /**
     * 短信登录
     *
     * @param SmsLoginRequest $request
     *
     * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
     * @throws \Illuminate\Validation\ValidationException
     */
    public function postSmsLogin(SmsLoginRequest $request)
    {
        $this->loginWithSms($request);

        return $this->intended();
    }
}